﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Adalbertus.BudgetPlanner.Domain;
using Adalbertus.BudgetPlanner.Domain.Repositories;

namespace Adalbertus.BudgetPlanner.Services
{
    public class BudgetPlanService : BaseService<BudgetPlan>, IBudgetPlanService
    {
        public BudgetPlanService(IRepositoryFactory repositoryFactory, IUnitOfWorkProvider unitOfWorkProvider)
            : base(repositoryFactory, unitOfWorkProvider)
        {
        }

        public void RemoveDetail(BudgetPlanDetail detail)
        {
            using (IUnitOfWork unitOfWork = UnitOfWorkProvider.OpenUnitOfWork())
            {
                IRepository<BudgetPlanDetail> budgetPlanRepository = RepositoryFactory.CreateRepository<BudgetPlanDetail>(unitOfWork);
                budgetPlanRepository.Remove(detail);
                unitOfWork.Commit();
            }
        }
    }
}
